package com.umer.pinban.datafenxi.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.common.ui.recycleview.adapter.RecyclerviewBasicAdapter;
import com.common.ui.recycleview.base.ViewHolder;
import com.common.ui.recycleview.listener.OptListener;
import com.umer.pinban.R;
import com.umer.pinban.bean.staff.StaffBean;
import java.util.List;

public class StaffDataFenXiAdapter extends RecyclerviewBasicAdapter<StaffBean> {

    private OptListener optListener;

    public StaffDataFenXiAdapter(Context context, List<StaffBean> datas, int layoutId,
                                 OptListener optListener) {
        super(context, datas, layoutId);
        this.optListener = optListener;
    }

    @Override
    public void convert(ViewHolder holder, final StaffBean staffBean, final int position) {

        TextView tv = holder.getView(R.id.tv);
        if(!TextUtils.isEmpty(staffBean.getName())){
            tv.setText(staffBean.getName());
        }
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                optListener.onOptClick(v,position);
            }
        });
        boolean select = staffBean.isSelect();
        if(select){
            tv.setTextColor(Color.parseColor("#ffffff"));
            tv.setBackgroundResource(R.drawable.shape7);
        }else {
            tv.setTextColor(Color.parseColor("#181818"));
            tv.setBackgroundResource(R.drawable.shape24);
        }
    }
}
